import BuffUtil from '@/BuffUtil';
import ItemUtil from '@/ItemUtil';
import BaseUtil from '@/BaseUtil';
import UnitCommon from 'code/Core/Common/UnitCommon';
export default class Item_恐鳌之心 {
    static id = 'esaz';
    static 名称: string = '恐鳌之心';
    static 描述: string = '极大提升生命回复速度';
    static 图标: string = 'ReplaceableTextures\\CommandButtons\\BTNHeartOfAszune.blp';
    static buffId: string = 'buff_item_longxin';
    static buffType: AppBuffType = {
        id: 'buff_item_longxin',
        name: Item_恐鳌之心.名称,
        ubertip: Item_恐鳌之心.描述,
        art: Item_恐鳌之心.图标,
        dur: 6,
        attribute: {
            生命恢复: 60,
            生命恢复增强: 5,
        },
        targetAttach: 'origin',
        targetArt: 'Units\\NightElf\\Owl\\Owl.mdl',
    };
    static 添加技能(目标: unit) {
        UnitAddAbility(目标, Item_恐鳌之心.id);
    }
    static 释放(x: number, y: number, 来源?: unit, 目标?: unit, d?: any) {
        BuffUtil.addBuff(目标, Item_恐鳌之心.buffId, 目标);
    }
    static 冷却池: Map<unit, number> = new Map();
    constructor() {
        BuffUtil.registerBuffType(Item_恐鳌之心.buffType);
        EventManager.onTakeDamage(Item_恐鳌之心.spellEffect);
        BaseUtil.onTimer(0.5, Item_恐鳌之心.计时器函数);
    }
    static 计时器函数() {
        for (let [key, value] of Item_恐鳌之心.冷却池) {
            if (value <= 0) {
                Item_恐鳌之心.冷却池.delete(key);
            }
        }
        return true;
    }
    static spellEffect(d: DamageEventData) {
        if (!ItemUtil.isUnitHasItem(d.target, Item_恐鳌之心.id)) return;
        if (Item_恐鳌之心.冷却池.has(d.target)) return;
        let p = GetUnitLifePercent(d.target);

        if (p > 40) return;
        Item_恐鳌之心.冷却池.set(d.target, 30 * UnitCommon.取冷却降低(d.target));
        Item_恐鳌之心.释放(0, 0, d.source, d.target);
    }
}
